package starter.data;

import java.util.ArrayList;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

import profile.logic.ProfileTests;

import createoffer.logic.CreateOfferTests;

public class ProfileTestCases {
	
	int startSize;
	
	public void runTestCases(ArrayList<String> codeInjection,
			int codeInjectionSize) throws InterruptedException {
		ProfileTests profileTests = new ProfileTests();
		profileTests.run(codeInjection, codeInjectionSize);
		
		ArrayList<String> webElements = new ArrayList<String>();
		webElements.add("email");
		webElements.add("password");
		profileCodeInjectionsTest(webElements, codeInjectionSize, webElements);
	}
	
	private void loginSuccesfull(ArrayList<String> webElements) throws InterruptedException {
		WebDriver driver = new FirefoxDriver();
		driver.get("https://www.snapsation.com/login/");
		WebElement email = driver.findElement(By.name(webElements.get(0)));
		email.sendKeys("damciodamcio666@gmail.com");
		WebElement password = driver.findElement(By.name(webElements.get(1)));
		password.sendKeys("admin123admin");
		email.submit();
		Thread.sleep(1800);
	}
	
	private void profileCodeInjectionsTest(ArrayList<String> codeInjection,
			int codeInjectionSize, ArrayList<String> webElements) throws InterruptedException {
		loginSuccesfull(webElements);
		for(startSize = 0; startSize < codeInjectionSize; startSize++){
			WebDriver driver = new FirefoxDriver();
			String link = "https://www.snapsation.com/" + codeInjection.get(startSize).toString();
			driver.get(link);
		}
		
	}
	
	
	
}
